package com.yangquan.ayuan.synchronizedTest;

public class SynchronizedWait {

    private final Object lock = new Object();

    public void method() throws InterruptedException {
        // 非同步代码
        System.out.println("Non-synchronized code");

        // 同步代码块
        synchronized (lock) {
            lock.wait();
            System.out.println("Synchronized code block");
        }
    }


    public static void main(String[] args) throws InterruptedException {
        SynchronizedWait synchronizedWait = new SynchronizedWait();
        synchronizedWait.method();
    }
}
